package co.sanduche.behave.presenters;

import java.util.List;

import co.sanduche.behave.mmos.AcudienteMMO;
import co.sanduche.behave.views.SplashscreenView;
import co.sanduche.models.Models.Estudiante;
import co.sanduche.util.EPCallback;

public class SplashscreenPresenter {
	private SplashscreenView splashscreenView;
	private AcudienteMMO acudienteMMO;

	public SplashscreenPresenter(SplashscreenView splashscreenActivity) {
		splashscreenView = splashscreenActivity;
		acudienteMMO = new AcudienteMMO();
	}

	public void goNext() {
		acudienteMMO.getEstudiantes(new EPCallback<List<Estudiante>>() {

			@Override
			public void onSuccess(List<Estudiante> val) {

				if (val.size() == 1) {
					splashscreenView.goToStudentActivity(val.get(0).getId());
				} else {
					splashscreenView.goToStudentsActivity();
				}
			}

			@Override
			public void onFailure(Throwable e) {

				splashscreenView.goToLoginActivity();

			}
		});
	}

}
